use crate::prelude::*;
use template::Templates;

mod template;

pub fn spawn_player(ecs: &mut World, pos: Point) {
    ecs.push((
        // 添加一个当作标签使用的组件
        Player{ map_level: 0},
        pos,
        // 玩家角色的外观信息
        Render{
            color: ColorPair::new(WHITE, BLACK),
            glyph: to_cp437('@'),
        },
        Health{ current: 10, max: 10},
        // 可见的图块
        FieldOfView::new(8),
        Damage(1),
    ));
}

/// 产生护身符
pub fn spawn_amulet_of_yala(ecs: &mut World, pos: Point){
    ecs.push((
        Item,
        AmuletOfYala,
        pos,
        Render{
            color: ColorPair::new(WHITE, BLACK),
            glyph: to_cp437('|'),
        },
        Name("Amulet of Yala".to_string()),
    ));
}

pub fn spawn_level (
    ecs: &mut World,
    rng: &mut RandomNumberGenerator,
    level: usize,
    spawn_points: &[Point],
) {
    let template = Templates::load();
    template.spawn_entities(ecs, rng, level, spawn_points);
}